import request from '@/utils/request'

// 分页获取子账户
export function fetchList(query) {
  return request({
    url: '/api/v1/user/page', // authority pageNumber	pageSize
    method: 'get',
    params: query
  })
}
export function getAllUser() {
  return request({
    url: '/api/v1/user/role-user', // authority pageNumber	pageSize
    method: 'get'
  })
}
// 获取用户基本信息
export function getUser(username) {
  return request({
    url: '/api/v1/user/?username=' + username,
    method: 'get'
  })
}

export function delUser(username) {
  return request({
    url: '/api/v1/user/?username=' + username,
    method: 'delete'
  })
}

export function editUser(data) {
  return request({
    url: '/api/v1/user/info',
    method: 'post',
    data: data
  })
}
export function resetPass(data) {
  return request({
    url: '/api/v1/auth/password/reset',
    method: 'post',
    data: data
  })
}

// 添加子账户 /api/v1/auth/reg
// {"authority": "ROLE_USER",
//   "captcha": "654321",
//   "companyId": "5a3e7bb4cad5582584433618",
//   "mobile": "110",
//   "name": "子账户一",
//   "password": "111111"
// }
export function addUser(subUser) {
  return request({
    url: '/api/v1/auth/reg',
    method: 'post',
    data: subUser
  })
}

export function addSubUser(subUser) {
  return request({
    url: '/api/v1/user/role-user',
    method: 'post',
    data: subUser
  })
}

